SELECT   t7.*,
         t8.[ntext3]
FROM     (SELECT DISTINCT t5.*,
                          t6.[tp_Ordinal],
                          t4.[tp_ID]      AS c14,
                          t10.[nvarchar6] AS c14c13
          FROM   (SELECT   TOP 101 t1.[Type]                         AS c0,
                                   UserData.[nvarchar10],
                                   UserData.[datetime1],
                                   UserData.[tp_IsCurrentVersion],
                                   t1.[TimeCreated]                  AS c4,
                                   t2.[tp_ID]                        AS c6c8,
                                   UserData.[nvarchar4],
                                   UserData.[nvarchar9],
                                   UserData.[int3],
                                   UserData.[tp_Created],
                                   UserData.[tp_ModerationStatus],
                                   UserData.[tp_Level],
                                   UserData.[tp_SiteId],
                                   UserData.[tp_LeafName],
                                   UserData.[tp_CalculatedVersion],
                                   UserData.[nvarchar1],
                                   UserData.[tp_HasCopyDestinations],
                                   UserData.[nvarchar6],
                                   UserData.[tp_DirName],
                                   UserData.[tp_HasAttachment],
                                   t1.[LeafName]                     AS c3,
                                   t2.[nvarchar1]                    AS c6c7,
                                   t2.[tp_Created]                   AS c6c11,
                                   UserData.[tp_DeleteTransactionId],
                                   t1.[ScopeId]                      AS c2,
                                   UserData.[tp_UIVersion],
                                   t2.[nvarchar5]                    AS c6c10,
                                   UserData.[nvarchar3],
                                   UserData.[float1],
                                   UserData.[nvarchar8],
                                   UserData.[tp_ID],
                                   UserData.[tp_CopySource],
                                   UserData.[datetime2],
                                   UserData.[nvarchar5],
                                   t3.[nvarchar6]                    AS c12c13,
                                   CASE 
                                     WHEN DATALENGTH(t1.DirName) = 0 THEN t1.LeafName
                                     WHEN DATALENGTH(t1.LeafName) = 0 THEN t1.DirName
                                     ELSE t1.DirName + N'/' + t1.LeafName
                                   END AS c1,
                                   UserData.[int4],
                                   UserData.[nvarchar2],
                                   t1.[DirName]                      AS c5,
                                   UserData.[tp_ContentType],
                                   UserData.[int1],
                                   UserData.[nvarchar7],
                                   UserData.[tp_ContentTypeId],
                                   t2.[nvarchar4]                    AS c6c9
                  FROM     UserData
                           LEFT OUTER LOOP JOIN Docs AS t1 WITH (NOLOCK)
                             ON (1 = 1
                                 AND UserData.[tp_RowOrdinal] = 0
                                 AND t1.SiteId = UserData.tp_SiteId
                                 AND t1.SiteId = @L2
                                 AND t1.DirName = UserData.tp_DirName
                                 AND t1.LeafName = UserData.tp_LeafName
                                 AND t1.Level = UserData.tp_Level
                                 AND t1.IsCurrentVersion = 1
                                 AND (1 = 1))
                           LEFT OUTER JOIN AllUserData AS t2 WITH (NOLOCK ,INDEX = AllUserData_PK)
                             ON (UserData.[int1] = t2.[tp_ID]
                                 AND UserData.[tp_RowOrdinal] = 0
                                 AND t2.[tp_RowOrdinal] = 0
                                 AND ((t2.tp_IsCurrent = 1))
                                 AND t2.[tp_CalculatedVersion] = 0
                                 AND t2.[tp_DeleteTransactionId] = 0x
                                 AND t2.tp_ListId = @L3
                                 AND UserData.tp_ListId = @L4)
                           LEFT OUTER JOIN AllUserData AS t3 WITH (NOLOCK ,INDEX = AllUserData_PK)
                             ON (UserData.[int3] = t3.[tp_ID]
                                 AND UserData.[tp_RowOrdinal] = 0
                                 AND t3.[tp_RowOrdinal] = 0
                                 AND ((t3.tp_IsCurrent = 1))
                                 AND t3.[tp_CalculatedVersion] = 0
                                 AND t3.[tp_DeleteTransactionId] = 0x
                                 AND t3.tp_ListId = @L4
                                 AND UserData.tp_ListId = @L4)
                  WHERE    UserData.tp_ListID = @L4
                           AND ((UserData.tp_IsCurrent = 1))
                           AND UserData.tp_SiteId = @L2
                           AND (UserData.tp_DirName = @DN)
                           AND UserData.tp_RowOrdinal = 0
                           AND (t1.SiteId = @L2
                                AND (t1.DirName = @DN))
                  ORDER BY UserData.[tp_ID] Asc) AS t5
                 LEFT OUTER JOIN UserDataJunctions AS t6
                   ON t5.[tp_SiteId] = t6.[tp_SiteId]
                      AND t5.[tp_DeleteTransactionId] = t6.[tp_DeleteTransactionId]
                      AND t5.[tp_IsCurrentVersion] = t6.[tp_IsCurrentVersion]
                      AND t5.[tp_DirName] = t6.[tp_DirName]
                      AND t5.[tp_LeafName] = t6.[tp_LeafName]
                      AND t5.[tp_CalculatedVersion] = t6.[tp_CalculatedVersion]
                      AND t5.[tp_Level] = t6.[tp_Level]
                 LEFT OUTER JOIN UserDataJunctions AS t4
                   ON t5.[tp_SiteId] = t4.[tp_SiteId]
                      AND t5.[tp_DeleteTransactionId] = t4.[tp_DeleteTransactionId]
                      AND t5.[tp_IsCurrentVersion] = t4.[tp_IsCurrentVersion]
                      AND t5.[tp_DirName] = t4.[tp_DirName]
                      AND t5.[tp_LeafName] = t4.[tp_LeafName]
                      AND t5.[tp_CalculatedVersion] = t4.[tp_CalculatedVersion]
                      AND t5.[tp_Level] = t4.[tp_Level]
                      AND t6.[tp_Ordinal] = t4.[tp_Ordinal]
                      AND t4.[tp_FieldId] = '{fdda84e2-205c-42dc-9f8a-16264110a70e}'
                 LEFT OUTER JOIN AllUserData AS t10 WITH (NOLOCK ,INDEX = AllUserData_PK)
                   ON (t10.[tp_ListId] = @L4
                       AND t10.[tp_Id] = t4.[tp_ID]
                       AND t10.[tp_RowOrdinal] = 0
                       AND t10.[tp_CalculatedVersion] = 0
                       AND t10.[tp_DeleteTransactionId] = 0x)) AS t7
         LEFT OUTER JOIN UserData AS t8 WITH (NOLOCK)
           ON t7.[tp_SiteId] = t8.[tp_SiteId]
              AND t7.[tp_DeleteTransactionId] = t8.[tp_DeleteTransactionId]
              AND t7.[tp_IsCurrentVersion] = t8.[tp_IsCurrentVersion]
              AND t7.[tp_DirName] = t8.[tp_DirName]
              AND t7.[tp_LeafName] = t8.[tp_LeafName]
              AND t7.[tp_CalculatedVersion] = t8.[tp_CalculatedVersion]
              AND t7.[tp_Level] = t8.[tp_Level]
              AND t8.[tp_RowOrdinal] = 0
ORDER BY t7.tp_ID Asc,
         t7.[tp_Ordinal]
OPTION (FORCE ORDER)